package com.yowasa.xiuxian.engine.battle.enemy.strategy;

import com.google.common.collect.Lists;
import com.yowasa.xiuxian.annoations.BS;
import com.yowasa.xiuxian.engine.battle.strategy.BaseSpellStrategy;
import com.yowasa.xiuxian.entity.bo.battle.BattleContent;
import com.yowasa.xiuxian.entity.bo.battle.UserBattleContent;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.ElementEnum;
import com.yowasa.xiuxian.exception.HandlerException;
import com.yowasa.xiuxian.service.helper.BattleHelper;
import com.yowasa.xiuxian.util.RandomUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@BS(name = "妖兽攻击")
@Order(1006)
@Component
public class YaoShouGongJi extends BaseSpellStrategy {
    @Autowired
    private BattleHelper battleHelper;

    @Override
    public ElementEnum getElement() {
        return null;
    }

    @Override
    public void action(UserBattleContent first, UserBattleContent second, BattleContent content) {
        int dmg;
        String desc;
        int i = RandomUtil.randomInt(1);
        if (i == 0) {
            int orgAtk = first.getBattleInfo().getAtk();
            int def = second.getBattleInfo().getDef();
            int atk = (int) (orgAtk * 1.2);
            dmg = battleHelper.calAtk(atk, def);
            desc = "撕咬";
        } else {
            int orgAtk = first.getBattleInfo().getSpell();
            int def = second.getBattleInfo().getRes();
            int atk = (int) (orgAtk * 1.2);
            dmg = battleHelper.calSpell(atk, def);
            desc = "吐息";
        }
        battleHelper.autoAction(this, first, second, content, dmg, desc);
    }

    @Override
    public void limit(UserBO user) {
        throw new HandlerException("无法学习妖兽的攻击手段");
    }

    @Override
    public String limitDesc() {
        return "无";
    }

    @Override
    public String desc() {
        return "随机使用撕咬和吐息两种攻击形式,均具有1.2倍的加成";
    }


}
